﻿using CarEdge.Infrastructure.Dto.Request.Consume;
using CarEdge.Infrastructure.Dto.Request.Reservation;
using CarEdge.Service.Interface;
using CarEdge.Service.Interface.Reservation;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace CarEdge.Admin.Controllers.Reservation
{
  
    public class ReservationController : BaseController
    {
        private readonly I_Reservation_EFCore _Reservation_Service;
        private readonly IConfiguration _configuration;

        /// <summary>
        /// 预约管理
        /// </summary>
        /// <param name="login_Service"></param>
        /// <param name="Reservation_Service"></param>
        /// <param name="configuration"></param>
        public ReservationController(I_Login_Service login_Service, I_Reservation_EFCore Reservation_Service, IConfiguration configuration) : base(login_Service)
        {
            _Reservation_Service = Reservation_Service;
            _configuration = configuration;
        }
        /// <summary>
        /// 通过activeName查询产品类型
        /// </summary>
        /// <param name="activeName"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetReservationBykey(string activeName)
        {
            var result = await _Reservation_Service.GetReservationByid(activeName);
            return Ok(result);
        }
        /// <summary>
        /// 获取所有技师
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetAllUser(string date)
        {
            var result = await _Reservation_Service.GetAllUser(date);
            return Ok(result);
        }
        /// <summary>
        /// 获取当前添加数据(产品)
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> bindproductbyids(string pids)
        {
            var result = await _Reservation_Service.bindproductbyids(pids);
            return Ok(result);
        }
        /// <summary>
        /// 获取当前添加数据(套餐)
        /// </summary>
        /// <param name="setmenuids"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> bindsetmenubyids(string setmenuids)
        {
            var result = await _Reservation_Service.bindsetmenubyids(setmenuids);
            return Ok(result);
        }
        /// <summary>
        ///  获取当前添加数据(所有)
        /// </summary>
        /// <param name="pids"></param>
        /// <param name="setmenuids"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> bindallbyids(string pids, string setmenuids)
        {
            var result = await _Reservation_Service.bindallbyids(pids, setmenuids);
            return Ok(result);
        }

        /// <summary>
        /// 添加预约
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> addreservation(Reservation_Request_Dto dto)
        {
            var result = await _Reservation_Service.addreservation(dto);
            return Ok(result);
        }
        /// <summary>
        /// 获取所有预约
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> bindallreservation(string? key = "")
        {
            var result = await _Reservation_Service.bindallreservation(key ?? "");
            return Ok(result);
        }

        /// <summary>
        /// 修改预约状态
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> updatereservation(Reservation_Request_Dto dto)
        {
            var result = await _Reservation_Service.updatereservation(dto);
            return Ok(result);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetName(string phone)
        {
            var result = await _Reservation_Service.GetName(phone);
            return Ok(result);
        }
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Recharge(Consume_Request_Dto dto)
        {
            var result = await _Reservation_Service.Recharge(dto);
            return Ok(result);
        }
    }
}
